//
//  GymTableViewCell.m
//  Frame
//
//  Created by 这是工作本 on 16/1/12.
//  Copyright © 2016年 这是工作本. All rights reserved.
//

#import "GymTableViewCell.h"

@interface GymTableViewCell ()
@property (nonatomic, retain) UIImageView *image;
@property (nonatomic, retain) UILabel *la;
@property (nonatomic, retain) UILabel *adress;
@property (nonatomic, retain) UIImageView *imageA;
@property (nonatomic, retain) UILabel *condition;
@property (nonatomic, retain) UILabel *price;
@end

@implementation GymTableViewCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubview];
    }
    return self;
}

- (void)cellForData:(VenuesList *)list
{
    
    [self.image sd_setImageWithURL:list.imgSrc placeholderImage:nil];
    self.la.text = list.name;
    self.adress.text = list.distance;
    NSString *fraction = [NSString stringWithFormat:@"%ld", list.fraction];
    self.condition.text = fraction;
    NSString *price = [NSString stringWithFormat:@"%ld", list.price];
    self.price.text = price;
    
    
}

- (void)createSubview
{
    //图片
    self.image = [[UIImageView alloc] initWithFrame:CGRectMake(5 * ScreenWidth, 5 * ScreenHeigth, 125 * ScreenWidth,   55 * ScreenHeigth )];
//    self.image.image = [[UIImage imageNamed:@"img_tp02.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self.contentView addSubview:self.image];
    //,名字
    self.la = [[UILabel alloc] initWithFrame:CGRectMake(self.image.frame.origin.x + self.image.frame.size.width + 20 * ScreenWidth, self.image.frame.origin.y, 200 * ScreenWidth, 30 * ScreenHeigth)];
//    self.la.text = @"优肯智能篮球馆";
    self.la.font = [UIFont systemFontOfSize:13.0 * ScreenWidth];
    self.la.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 /255.0 alpha:1.0];
    [self.contentView addSubview:self.la];
    //距离
    self.adress = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 60 * ScreenWidth, self.la.frame.origin.y  , 60 * ScreenWidth, 30 * ScreenHeigth)];
//    self.adress.text = @"1.5km";
    self.adress.font = [UIFont systemFontOfSize:11.0 * ScreenWidth];
    self.adress.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 /255.0 alpha:1.0];
    [self.contentView addSubview:self.adress];

    
    //评分
    
    self.imageA = [[UIImageView alloc] initWithFrame:CGRectMake(self.la.frame.origin.x, self.la.frame.origin.y + self.la.frame.size.height , 12 * ScreenWidth, 12 * ScreenHeigth)];
    self.imageA.image = [UIImage imageNamed:@"iocn_xingxing_h.png"];
    [self.contentView addSubview:self.imageA];

    
    //状态
    self.condition = [[UILabel alloc] initWithFrame:CGRectMake(self.la.frame.origin.x, self.imageA.frame.origin.y + self.imageA.frame.size.height , 30 * ScreenWidth, 20 * ScreenHeigth)];
//    self.condition.text = @"空闲";
    self.condition.font = [UIFont systemFontOfSize:12.0 * ScreenWidth];
    self.condition.textColor = [UIColor colorWithRed:84 / 255.0 green:185 / 255.0 blue:52 /255.0 alpha:1.0];
    [self.contentView addSubview:self.condition];

    
    
    //图标
    
    UIImageView *logo = [[UIImageView alloc] initWithFrame:CGRectMake(self.adress.frame.origin.x, self.condition.frame.origin.y , 10 * ScreenWidth, 10 * ScreenHeigth)];
    logo.image = [[UIImage imageNamed:@"iocn_rmb.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self.contentView addSubview:logo];

    
    
    //价格
    
    self.price = [[UILabel alloc] initWithFrame:CGRectMake(logo.frame.origin.x + logo.frame.size.width, logo.frame.origin.y , 30 * ScreenWidth, 10 * ScreenHeigth)];
//    self.price.text = @"400";
    self.price.font = [UIFont systemFontOfSize:12.0 * ScreenWidth];
    self.price.textColor = [UIColor colorWithRed:252 / 255.0 green:162 / 255.0 blue:44 /255.0 alpha:1.0];
    [self.contentView addSubview:self.price];

    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
